package com.srd.phone.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.GridLayout;
import android.widget.RadioButton;

import com.shengrongdai.srd.R;

/**
 * 注册企业 类型
 */
public class RegisterEnterpriseTypeActivity extends BaseActivity implements View.OnClickListener {

    private GridLayout gl_rb;
    private RadioButton rb_qiye;
    private RadioButton rb_shiye;
    private RadioButton rb_minban;
    private RadioButton rb_geti;
    private RadioButton rb_shehui;
    private RadioButton rb_dangzheng;
    private Button bt_next;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_register_enterprise_type);
        initView();
        initData();
    }

    @Override
    public void initView() {
        super.initView();
        tv_common_title.setText("企业类型");
        gl_rb = (GridLayout) findViewById(R.id.gl_rb);
        rb_qiye = (RadioButton) findViewById(R.id.rb_qiye);
        rb_shiye = (RadioButton) findViewById(R.id.rb_shiye);
        rb_minban = (RadioButton) findViewById(R.id.rb_minban);
        rb_geti = (RadioButton) findViewById(R.id.rb_geti);
        rb_shehui = (RadioButton) findViewById(R.id.rb_shehui);
        rb_dangzheng = (RadioButton) findViewById(R.id.rb_dangzheng);
        bt_next = (Button) findViewById(R.id.bt_next);

        rb_qiye.setOnClickListener(this);
        rb_shiye.setOnClickListener(this);
        rb_minban.setOnClickListener(this);
        rb_geti.setOnClickListener(this);
        rb_shehui.setOnClickListener(this);
        rb_dangzheng.setOnClickListener(this);
        bt_next.setOnClickListener(this);
    }

    public void checkedRadioButton(int id) {
        int count = gl_rb.getChildCount();
        for (int i = 0; i < count; i++) {
            RadioButton rb = (RadioButton) gl_rb.getChildAt(i);
            if (rb.getId() == id) {
                rb.setChecked(true);
            } else {
                rb.setChecked(false);
            }
        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.rb_qiye:
                checkedRadioButton(R.id.rb_qiye);
                break;
            case R.id.rb_shiye:
                checkedRadioButton(R.id.rb_shiye);
                break;
            case R.id.rb_minban:
                checkedRadioButton(R.id.rb_minban);
                break;
            case R.id.rb_geti:
                checkedRadioButton(R.id.rb_geti);
                break;
            case R.id.rb_shehui:
                checkedRadioButton(R.id.rb_shehui);
                break;
            case R.id.rb_dangzheng:
                checkedRadioButton(R.id.rb_dangzheng);
                break;
            case R.id.bt_next:
                startActivity(new Intent(mContext, RegisterEnterpriseInfoActivity.class));
                break;
        }
    }
}
